# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=hstdb
pkgver=2.1.0
pkgrel=2
pkgdesc="Better history management for Zsh"
url="https://github.com/AlexanderThaller/hstdb"
# riscv64: textrels
# s390x: fails to build nix crate
arch="all !riscv64 !s390x"
license="MIT"
makedepends="cargo cargo-auditable"
source="https://github.com/AlexanderThaller/hstdb/archive/$pkgver/hstdb-$pkgver.tar.gz
	fix-format_duration-panicing.patch
	replace-pretty_env_logger.patch
	default-histfile-path.patch
	rename-text_excluded.patch
	strip-features.patch
	update-getrandom.patch
	"

# Disable histdb-import that depends on sqlite.
_cargo_opts="--frozen --no-default-features"

prepare() {
	cargo fetch --locked

	default_prepare

	# Update Cargo.lock after patching.
	cargo fetch
}

build() {
	cargo auditable build $_cargo_opts --release
}

check() {
	cargo test $_cargo_opts
}

package() {
	install -D -m755 target/release/$pkgname -t "$pkgdir"/usr/bin/
}

sha512sums="
1a29c81e52822823967178e53f9135ba66ed156ebe36145e778f48e8390e7e6b8420897d07d40dfc9434d3068fdbafc1831bf441d127d2f3ba42d7a2e686188e  hstdb-2.1.0.tar.gz
ffed0c79621123e5cf8fdce729e7d0e6d9d077e975fd0c5c7c3e83b91e8ff7071edf309c5b165241e3f24b7b20acf04618e5a4e2e856843e9f9b1927c90c7136  fix-format_duration-panicing.patch
147c543d2dc9055c9072f5eba81be27f0dd911fe3867d460982fedd4db1a50043509df119d3a9759303465a6c97506b3dc37db1c26c7d7557b6ec40248b4a482  replace-pretty_env_logger.patch
80eaa11a2114e0352ec99bf2db955136cc08fb85a48b978254c2d6ea806d1718058b8972135f33f7ed8a22b800843b6e421ca15e908b891d5f68cddf06f106fb  default-histfile-path.patch
d8a636d5b035bf2ce79db4be34f3011adde6a6015da1db22308e796f14a557b8053caeb2f3ff7b8391198ff97df6702bfbd0c9a81bad22e2d9ec6294f6c97c8b  rename-text_excluded.patch
2c001f5a40e962acf22006854853a52abd258148042b43e32086aeacdaaffa483ffa25d9ba082206bf63e66a22ba45f9eec727299c5fe0b91127b05ddbe28a43  strip-features.patch
67014d35ca80ab5b7f1ccebd887c7e863a069142d42f1e8a415c28f22114d9a6514ba3efc3f4dbc9f8f33c6ad2ef907a8a00c08d9d4c07b8c13ad1f6ecf5c9cb  update-getrandom.patch
"
